/* Copyright (c) 2003-2007 Caleb Doise
 * 
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation
 * files (the "Software"), to deal in the Software without restriction,
 * including without limitation the rights to use, copy, modify, merge,
 * publish, distribute, sublicense, and/or sell copies of the Software,
 * and to permit persons to whom the Software is furnished to do so,
 * subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

using System;
using System.Runtime.InteropServices;


namespace SharpScraps.Win32
{
    
    public static class SHELL32
    {       

        [DllImport("Shell32.dll", CharSet=CharSet.Auto)]
        public extern static IntPtr SHGetFileInfo(
            string pszPath,
            UInt32 dwFileAttributes,
            out SHFILEINFO psfi,
            UInt32 cbFileInfo,
            UInt32 uFlags);

        #region Constants

        public class ShGetFileInfoConstants
        {
            public const UInt32 SHGFI_ICON              = 0x000000100;     
            public const UInt32 SHGFI_DISPLAYNAME       = 0x000000200;     
            public const UInt32 SHGFI_TYPENAME          = 0x000000400;     
            public const UInt32 SHGFI_ATTRIBUTES        = 0x000000800;     
            public const UInt32 SHGFI_ICONLOCATION      = 0x000001000;     
            public const UInt32 SHGFI_EXETYPE           = 0x000002000;     
            public const UInt32 SHGFI_SYSICONINDEX      = 0x000004000;     
            public const UInt32 SHGFI_LINKOVERLAY       = 0x000008000;     
            public const UInt32 SHGFI_SELECTED          = 0x000010000;     
            public const UInt32 SHGFI_ATTR_SPECIFIED    = 0x000020000;     
            public const UInt32 SHGFI_LARGEICON         = 0x000000000;    
            public const UInt32 SHGFI_SMALLICON         = 0x000000001;    
            public const UInt32 SHGFI_OPENICON          = 0x000000002;    
            public const UInt32 SHGFI_SHELLICONSIZE     = 0x000000004;    
            public const UInt32 SHGFI_PIDL              = 0x000000008;    
            public const UInt32 SHGFI_USEFILEATTRIBUTES = 0x000000010;    
            public const UInt32 SHGFI_ADDOVERLAYS       = 0x000000020;    
            public const UInt32 SHGFI_OVERLAYINDEX      = 0x000000040;                                                                            
        }

        #endregion

    } // class SHELL32


    [StructLayout(LayoutKind.Sequential)]
    public struct SHFILEINFO
    {            
        public IntPtr hIcon;
        public int iIcon;
        public UInt32 dwAttributes;

        [MarshalAs(UnmanagedType.ByValTStr, SizeConst=260)]
        public string szDisplayName;

        [MarshalAs(UnmanagedType.ByValTStr, SizeConst=80)]
        public string szTypeName;
    } // struct SHFILEINFO


    [StructLayout(LayoutKind.Sequential)]
    public struct APPBARDATA
    {
        public static readonly int cbSize = Marshal.SizeOf(typeof(APPBARDATA));
        public IntPtr hWnd;
        public UInt32 uCallbackMessage;
        public UInt32 uEdge;
        public RECT rc;
        public IntPtr lParam;
    } // struct APPBARDATA

            
} // namespace SharpScraps.Win32